<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>
<script>
  Array.prototype.sum = function () {
    var sum = 0;
    for(let i = 0; i < this.length; i++) {
      sum += this[i];
    }
    console.log(sum);
  }

  var arr = [1, 2, 3];
  arr.sum(); // => 6
</script>
</body>
</html>